// SCENARIO SCRIPT

// This is the special script for your entire scenario. It contains
// special encounters and code accessable from anywhere in the scenario. it also
// contains the code that initializes important special things in the
// scenario (like shops and names and descriptions of special items).

// You can create your own states, but you should give all of them numbers greater than
// or equal to 10.

beginscenarioscript;

variables;


int i,j,k,modifier,level;


body;

// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//    Names and descriptions of special items.
//    Names and effects of custom special abilities.
beginstate LOAD_SCEN_STATE;
	init_quest(0,"Kill the Ice Goblins", "Darius wants you to kill the ice goblins who have been attacking his writers.");
	init_special_item(0,"Dragon Horn", "This is a horn that is intricately carved with pictures of dragons.");
break;

// This is the state that is called only once at the very beginning of 
// the scenario. Some things that should go here:
//    The stuff in shops.
//    Creating horses and boats.
beginstate START_SCEN_STATE;

reset_dialog();
add_dialog_str(0,"This scenario will completely alter your party, irreversibly. If you want to bring another party into the scenario, now is your chance.",0);
add_dialog_choice(0,"Carry on with this party.");
add_dialog_choice(1,"Change the party.");
if(run_dialog(1) == 2) {
	end_scenario(2);
}

i = 0;
	k = 0;
	while(char_ok(i) == 0) {
		i = i + 1;
		}
			
	while(k <= 3) {
		j = 39;
		if(char_ok(k) == 1) {
			while(j >= 0) {
				destroy_char_item(k,j);
				j = j - 1;
			}
			if(k != i) {
				erase_char(k);
			}
		}
		k = k + 1;
	}
	
	level = (1 - get_level(i));
	set_level(i,5);
				
	modifier = 100;
	while(level < 1) {
		change_char_xp(i,-25 * modifier);
		level = level + 1;
	}
			
	modifier = 0;
	while(modifier <= 22) {
		set_char_trait(i,modifier,0);
		modifier = modifier + 1;
	}
	
	modifier = 0;
	while(modifier <= 19) {
		if(get_spell_level(i,0,modifier) > 0)
			change_spell_level(i,0,modifier,-1 * get_spell_level(i,0,modifier));
		if(get_spell_level(i,1,modifier) > 0)
			change_spell_level(i,1,modifier,-1 * get_spell_level(i,1,modifier));
		modifier = modifier + 1;
	}
	
	change_pc_skill_pts(i,-1 * (get_char_skill_pts(i)));
	
	j = 0;
	while (j < 32) {
		modifier = get_stat(i,j);
		alter_stat(i,j,-1 * modifier);
		j = j + 1;
	}
	alter_stat(i,12,2);
	alter_stat(i,4,4);
	alter_stat(i,2,2);
	alter_stat(i,7,4);
	reward_give(13);
	reward_give(19);
	reward_give(51);
	reward_give(223);
	reward_give(314);
	change_spell_level(0,1,0,1);
	revive_party();	

// Initialize a few shops.
	
	// Shop 0 - armor
	add_item_to_shop(0,25,25);
	add_item_to_shop(0,26,20);
	add_item_to_shop(0,30,20);
	add_item_to_shop(0,31,10);
	add_item_to_shop(0,35,10);
	add_item_to_shop(0,121,15);
	add_item_to_shop(0,122,15);
	add_item_to_shop(0,126,3);
	add_item_to_shop(0,131,2);
	add_item_to_shop(0,111,15);
	add_item_to_shop(0,16,10);
	add_item_to_shop(0,136,10);
	add_item_to_shop(0,137,10);
	add_item_to_shop(0,141,5);
	
	// Shop 1 - weapons
	add_item_to_shop(1,45,25);
	add_item_to_shop(1,46,20);
	add_item_to_shop(1,50,15);
	add_item_to_shop(1,51,10);
	add_item_to_shop(1,55,5);
	add_item_to_shop(1,65,20);
	add_item_to_shop(1,66,10);
	add_item_to_shop(1,70,5);
	
	// Shop 2 - tools
	add_item_to_shop(2,170,500);
	add_item_to_shop(2,171,500);
	add_item_to_shop(2,172,30);
	add_item_to_shop(2,174,500);
	add_item_to_shop(2,177,500);
	
	// Shop 3 - missiles
	add_item_to_shop(3,85,500);
	add_item_to_shop(3,86,10);
	add_item_to_shop(3,90,10);
	add_item_to_shop(3,95,3);
	add_item_to_shop(3,100,20);
	add_item_to_shop(3,101,10);
	add_item_to_shop(3,105,10);

// Shop 4 - potions
	add_item_to_shop(4,220,4);
	add_item_to_shop(4,221,3);
	add_item_to_shop(4,222,3);
	add_item_to_shop(4,223,2);

	// Shop 5 - food
	
	add_item_to_shop(5,4,500);
	add_item_to_shop(5,6,500);
	add_item_to_shop(5,7,500);
break;

// This state is called every tick wherever the party is in the scenario.
// You can use the set_state
beginstate START_STATE;
break;

// Place your own states below. Give each a number at least 10.
beginstate 10;
break;
